package com.isoft.service.impl;

import com.isoft.service.DfoeDfieService;
import com.isoft.service.XmlFileHandler;
import org.springframework.stereotype.Component;

import java.nio.file.Path;

@Component
public class DfoeDfieFileHandler implements XmlFileHandler {        //其他XML文件处理器示例
    private final DfoeDfieService dfoeDfieService;

    public DfoeDfieFileHandler(DfoeDfieService dfoeDfieService) {
        this.dfoeDfieService = dfoeDfieService;
    }

    @Override
    public boolean supports(Path filePath) {
        String name = filePath.getFileName().toString().toUpperCase();
        return name.startsWith("DFOE-DFIE") && name.endsWith(".XML");
    }

    @Override
    public String handle(Path filePath) throws Exception {
        return dfoeDfieService.parseAndSave(filePath.toString());
    }
}
